package cn.yougou.serviceImpl;

import cn.yougou.dto.Dto;
import cn.yougou.mapper.YgAddressMapper;
import cn.yougou.pojo.YgAddress;
import cn.yougou.service.user.YgUserAddressService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class YgUserAddressServiceImpl implements YgUserAddressService {

    @Autowired
    private YgAddressMapper ygUserAddressMapper;


    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public List<YgAddress> selAddress(Integer id) {
        List <YgAddress> list = null;
        try{
            list = this.ygUserAddressMapper.selAddress(id);
        }catch (Exception e){
            e.printStackTrace();
        }
        System.out.println(list);
        return this.ygUserAddressMapper.selAddress(id);
    }

    /**
     * 新增数据
     *
     * @param ygAddress 实例对象
     * @return 影响行数
     */
    @Override
    public int addAddress(YgAddress ygAddress) {
        return this.ygUserAddressMapper.addAddress(ygAddress);
    }

    /**
     * 修改数据
     *
     * @param ygAddress 实例对象
     * @return 影响行数
     */
    @Override
    public int upAddress(YgAddress ygAddress) {
        return ygUserAddressMapper.upAddress(ygAddress);
    }


    /**
     * 通过主键删除数据
     *
     * @param addressId 主键
     * @return 影响行数
     */
    @Override
    public int deAddress(Integer addressId) {
        return ygUserAddressMapper.deAddress(addressId);
    }

    /**
     * 通过id修改默认地址
     *
     * @param id
     * @return 影响行数
     */
    @Override
    public int upzerofromone(Integer id) {
        return ygUserAddressMapper.upzerofromone(id);
    }

    /**
     * 通过defaultid查询默认地址
     *
     * @param id
     * @return 影响行数
     */
    @Override
    public YgAddress selMo(Integer id) {
        return ygUserAddressMapper.selMo(id);
    }

}
